<template>
  <router-view />
  <UploadVideoFloatButton />
</template>

<script setup lang="ts">
import { onMounted } from "vue";
import { useUserStore, useSystemStore } from "@/store";
import UploadVideoFloatButton from "@/components/Common/upload-video-float-button.vue";

interface Props {
  loginData?: any;
  configData?: any;
}

const props = defineProps<Props>();
const userStore = useUserStore();
const systemStore = useSystemStore();

onMounted(() => {
  // 初始化登录用户
  if (props.loginData) {
    userStore.loginAction(props.loginData);
  }

  // 初始化系统配置
  if (props.configData) {
    const config = {
      "ldap-enabled": props.configData["ldap-enabled"],
      systemName: props.configData["system.name"],
      systemLogo: props.configData["system.logo"],
      systemPcUrl: props.configData["system.pc_url"],
      systemH5Url: props.configData["system.h5_url"],
      resourceUrl: props.configData["resource_url"],
      memberDefaultAvatar: props.configData["member.default_avatar"],
      courseDefaultThumbs: props.configData["default.course_thumbs"],
      departments: props.configData["departments"],
      resourceCategories: props.configData["resource_categories"],
    };
    systemStore.saveConfigAction(config);
  }
});
</script>
